<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<title><?php echo C('defaultinfo.name');?> - Powered By可用可信HRM</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
		<meta name="description" content=""/>
		<meta name="author" content="可用可信HRM"/>
		<link rel="shortcut icon" href="__PUBLIC__/ico/favicon.png"/>
		<link rel="stylesheet" href="__PUBLIC__/css/bootstrap.css">
		<link rel="stylesheet" href="__PUBLIC__/css/hrms.css">
		<script src="__PUBLIC__/js/jquery.min.js"></script>
		<script src="__PUBLIC__/js/bootstrap.min.js"></script>
		<script src="__PUBLIC__/js/nongli.js"></script>
		<script src="__PUBLIC__/js/calendar.js"></script>
		<!--[if lt IE 9]>
		<script src="__PUBLIC__/js/html5shiv.min.js"></script>
		<script src="__PUBLIC__/js/respond.min.js"></script>
		<![endif]-->
	</head>
	<body>
<?php echo W('Navigation');?>
<div class="body-right">
	<div class="row-table">
		<div class="row-table-title">员工列表</div>
		<div class="row-table-body">
			<p class="form-title">
				<div class="pull-right">
					<a class="btn btn-primary" href="<?php echo U('core/user/output');?>" target="_blank">导出在职员工</a>
					<a class="btn btn-primary" href="<?php echo U('core/user/output');?>&status=2" target="_blank">导出离职员工</a>
					<a class="btn btn-primary btn-xs" href="<?php echo U('core/user/adduser');?>">添加员工</a>
				</div>
				
				<?php if($searchs): ?><div class="col-sm-2">搜索“<?php if($searchs.team): ?>【<?php echo ($searchs["team"]); ?>】<?php endif; ?><span class="color-red"><?php echo ($searchs["nickname"]); ?></span>”的用户列表</div>
				<?php else: ?>
				
				<?php if(is_array($status_array)): $i = 0; $__LIST__ = $status_array;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i; if($key == $status): echo ($vo); ?>&nbsp;&nbsp;&nbsp;<?php else: ?><a href='<?php echo U("core/user/index","status=$key");?>'><?php echo ($vo); ?></a>&nbsp;&nbsp;&nbsp;<?php endif; endforeach; endif; else: echo "" ;endif; endif; ?>
				<form action="<?php echo U("core/user/index");?>" method="post" class="form-inline">
					<div class="form-group col-sm-2">
				    	<label for="name">团队选择：</label>
				    		<select name="dep" class="form-control">
				    			<option value="">请选择团队</option>
				    			<?php if(is_array($dep)): $i = 0; $__LIST__ = $dep;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["department_id"]); ?>"><?php echo ($vo["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
				    		</select>
				    </div>
					<div class="input-group col-sm-2">
				      <div class="input-group-addon">姓名查询：</div>
				      <input type="text" class="form-control" name="nickname" placeholder="请输入姓名">
				    </div>
				    <button type="submit" class="btn btn-info">查询</button>
			    </form>
			    
			    
			</p>
			<table class="table table-hover table-striped" style="margin-bottom:0px;">
				<tbody>
					<tr>
						<?php if($searchs): ?><th>员工状态</th><?php endif; ?>
						<th>姓名</th>
						<!--<th>性别</th>-->
						<th>部门 </th>
						<th>职务</th>
						<th>员工状态</th><!--
						<th>员工类型</th>-->
						<!--<th>保险情况</th>-->
						<th>手机</th>
						<th>银行卡号</th>
						<th>身份证</th>
						<th>操作</th>
						<th>人事审核</th>
					</tr>
					<?php if(is_array($userlist)): $i = 0; $__LIST__ = $userlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
						<?php if($searchs): ?><td><?php if($vo['status'] == 0): ?>未激活<?php elseif($vo['status'] == 1): ?>在职<?php elseif($vo['status'] == 2): ?>离职<?php else: ?>退休<?php endif; ?></td><?php endif; ?>
						<td><a href="javascrip:;" onclick="getuser('<?php echo ($vo["name"]); ?>')"><?php echo ($vo["nickname"]); ?></a></td>
						<!--<td><?php if($vo['sex'] == 1): ?>男<?php elseif($vo['sex'] == 2): ?>女<?php else: ?>未知<?php endif; ?></td>-->
						<td><?php echo ($vo["dep"]); ?></td>
						<td><?php echo ($vo["position_name"]); ?></td>
						<!--<td><?php if($vo['status'] == 0): ?>未激活<?php elseif($vo['status'] == 1): ?>在职<?php elseif($vo['status'] == 2): ?>离职<?php else: ?>退休<?php endif; ?></td>
						<td><?php if($vo['type'] == 0): ?>试用期<?php elseif($vo['type'] == 1): ?>正式工<?php elseif($vo['type'] == 2): ?>临时工<?php else: ?>其他<?php endif; ?></td>
						<td>
							<?php if($vo['work_status'] == 0): ?>正常
							<?php elseif($vo['work_status'] == 1): ?>
								休假
							<?php elseif($vo['work_status'] == 2): ?>
								出差
							<?php elseif($vo['work_status'] == 3): ?>
								请假
							<?php elseif($vo['work_status'] == 4): ?>
								调休<?php endif; ?>
						</td>-->
						<td><?php switch($vo["type"]): case "0": ?>试用期<?php break;?>
							<?php case "1": ?>正式工<?php break;?>
							<?php case "2": ?>临时工<?php break; endswitch;?></td>
						<!--<td><?php if($vo["baoxian"] == 1): ?>已买<?php else: ?>未买<?php endif; ?></td>-->
						<td><?php echo ($vo["telephone"]); ?></td>
						<td><?php echo ($vo["bankcard"]); ?></td>
						<td><?php echo ($vo["sfzid"]); ?></td>
						<td>
							<a href="<?php echo U('core/user/editinfo','id='.$vo['user_id']);?>">编辑</a><!--&nbsp;|&nbsp;
							<a href="<?php echo U('hrm/peibei/view','uid='.$vo['user_id']);?>">配备</a>&nbsp;|&nbsp;
							<a href="<?php echo U('hrm/staffcontract/index','user_id='.$vo['user_id']);?>">人事合同</a>&nbsp;|&nbsp;
							<a href="<?php echo U('hrm/archives/view','user_id='.$vo['user_id']);?>">人事档案</a>&nbsp;|&nbsp;
							<a href="javascript:void(0);" class="punch_in" rel="<?php echo ($vo["user_id"]); ?>" value="0">上班打卡</a>&nbsp;|&nbsp;
							<a href="javascript:void(0);" class="punch_out" rel="<?php echo ($vo["user_id"]); ?>" value="1">下班打卡</a>-->
						</td>
						<td>
							<?php switch($vo["v_status"]["status"]): case "0": ?><a href="javasctip:;" class="glyphicon glyphicon-remove-sign color-red"><?php switch($vo['v_status']['type']){ case "add": echo "新添加"; break; case "edit": echo "编辑"; break; } ?>未审核</a><?php break;?>
								<?php case "1": ?><span class="text-primary glyphicon glyphicon-ok-sign"><?php switch($vo['v_status']['type']){ case "add": echo "新添加"; break; case "edit": echo "编辑"; break; } ?>通过审核
									</span><?php break;?>
								<?php case "2": ?><span class="popovers btn btn-sm btn-danger glyphicon glyphicon-remove-sign" title="拒审原因！" data-container="body" data-toggle="popover" role="button" data-trigger="focus"  data-placement="right" data-content="<?php if($vo['v_status']['msg_back'] == ''): ?>未填写拒审原因！<?php else: echo ($vo["v_status"]["msg_back"]); endif; ?>"><?php switch($vo['v_status']['type']){ case "add": echo "新添加"; break; case "edit": echo "编辑"; break; } ?>已拒审</span><?php break; endswitch;?>
						</td>
					</tr><?php endforeach; endif; else: echo "" ;endif; ?>
				</tbody>
				<tfoot>
					<tr>
						<td colspan="9"><?php echo ($page); ?><div class="clear"></div></td>
					</tr>
				</tfoot>
			</table>
		</div>
	</div>
</div>
<div class="clear"></div>
<script type="text/javascript">

	function getuser(uname){	
		$('#alert').modal({
			show:true,
			remote:'<?php echo u("core/verify/view");?>'+'&uname='+uname+"&user_id=1"
		});
	}
	
	/**
	 * Ajax上班打卡
	 * 
	**/
	$('.punch_in').click(function(){
		var user_id = $(this).attr('rel');
		var punch_type = $(this).attr('value');

		$.ajax({
			type: "POST",
			dataType: "JSON",
			url: "<?php echo U('hrm/punch/add');?>",
			data: {user_id : user_id, punch_type : punch_type},
			success: function (data) {
				alert(data.info);
			},
			error: function(data) {
				alert(data.info);
			}
		});
	});
	
	/**
	 * Ajax下班打卡
	 * 
	**/
	$('.punch_out').click(function(){
		var user_id = $(this).attr('rel');
		var punch_type = $(this).attr('value');

		$.ajax({
			type: "POST",
			dataType: "JSON",
			url: "<?php echo U('hrm/punch/add');?>",
			data: {user_id : user_id, punch_type : punch_type},
			success: function (data) {
				alert(data.info);
			},
			error: function(data) {
				alert(data.info);
			}
		});
	});
	$(function () {
		$('body').click(function(){
			$(".popovers .table-hover").popover('destroy');
		});
	  	$(".popovers").hover(function(){
		  	$(".popovers .table-hover").popover('destroy');
		  	$(this).popover('show');
	  });
	  
	})
</script>
<div class="modal fade" id="alert" tabindex="-1" data-backdrop="static">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">提示信息</h4>
			</div>
			<div class="modal-body">
			<?php if(is_array($alert)): foreach($alert as $k=>$v): if(is_array($v)): foreach($v as $kk=>$vv): ?><div class="alert alert-<?php echo ($k); ?>">
					<?php echo ($vv); ?>
				</div><?php endforeach; endif; endforeach; endif; ?>
			</div>
		</div>
	</div>
</div>
<?php if(!empty($alert)): ?><script type="text/javascript">
	$('#alert').modal('show');
	var alert_n = setInterval('$("#alert").modal("hide")',1000);
	$('#alert').on('hide.bs.modal', function (e) {
		clearInterval(alert_n);
	});
</script><?php endif; ?>

		 <div id="footer">
			<div class="container">
				<p class="text-muted credit">
					可用可信HRM © 2016 <a href="http://www.dgpaotui.com" target="_blank">东莞市可用可信家庭服务有限公司</a>版权所有
				</p>
			</div>
		</div> 
	</body>
</html>